<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        /*div{*/
        /*    width: 300px;*/
        /*    padding: 10px;*/
        /*    background-color: rgba(0,0,0,0.3);*/
        /*    text-align: center;*/
        /*    position: relative;*/
        /*}*/
        /*[type="text"]{*/
        /*    padding: 10px  20px;*/
        /*    border: none;*/
        /*}*/
        /*img{*/
        /*    position: absolute;!*绝对定位*!*/
        /*    right: 70px;*/
        /*    top: 15px;*/
        /*}*/
        /*p{*/
        /*    color: red;*/
        /*}*/

        div{
            width: 300px;
            background-color: rgba(0,0,0,0.3);
            padding: 10px;
            position: absolute;/*参照物*/
        }
        input{
            padding: 10px 20px;
            border: none;/*去掉边框   0或none都可以*/
            width: 260px;
        }
        img{
            position: absolute;
            right: 30px;
            top: 13px;
        }
        p{
            font-size: 12px;
            color: red;
            margin: 0;
        }
    </style>
</head>
<body>
<div>
    <input type="text" placeholder="请输入用户名">
    <img src="yhm.png" alt="">
    <p>用户名不能为空！</p>
</div>
</body>
</html>